import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
// import Home from '../views/Home.vue'

const routes: Array<RouteRecordRaw> = [
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
  {
    path: '/',
    component: () => import(/* webpackChunkName: "about" */ '../views/Layout/index.vue'),
    children: [{
      path: '/',
      component: () => import(/* webpackChunkName: "about" */ '../views/workbench/index.vue'),
    }, {
      path: '/Articlemanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views//Articlemanagement/index.vue'),
    
    },{
      path: '/Articlemanagement/fity',
      component: () => import(/* webpackChunkName: "about" */ '../views//Articlemanagement/Fity.vue'),
    }, {
      path: '/Articlemanagement/qian',
      component: () => import(/* webpackChunkName: "about" */ '../views//Articlemanagement/Qian.vue'),
    }, {
      path: '/Knowledgebooklet',
      component: () => import(/* webpackChunkName: "about" */ '../views//Knowledgebooklet/index.vue'),
    }, {
      path: '/Pagemanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Pagemanagement/index.vue'),
    }, {
      path: '/Postermanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Postermanagement/index.vue'),
    }, {
      path: '/Commentmanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Commentmanagement/index.vue'),
    }, {
      path: '/Mailmanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Mailmanagement/index.vue'),
    }, {
      path: '/Filemanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Filemanagement/index.vue'),
    }, {
      path: '/Searchforrecords',
      component: () => import(/* webpackChunkName: "about" */ '../views/Searchforrecords/index.vue'),
    }, {
      path: '/Accessstatistics',
      component: () => import(/* webpackChunkName: "about" */ '../views/Accessstatistics/index.vue'),
    }, {
      path: '/Usermanagement',
      component: () => import(/* webpackChunkName: "about" */ '../views/Usermanagement/index.vue'),
    }, {
      path: '/SystemAdministration',
      component: () => import(/* webpackChunkName: "about" */ '../views/SystemAdministration/index.vue'),
    }]
  },{
    path:'/login',
    component: () => import(/* webpackChunkName: "about" */ '../views/Login/index.vue'),
  },{
    path:'/zhu',
    component: () => import(/* webpackChunkName: "about" */ '../views/Zhu/index.vue'),
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})
router.beforeEach((to,from,next)=>{
  const token=localStorage.getItem('token')
  if(!token && to.path!=="/login"  && to.path!=="/zhu"){
    next('/login'),next('/zhu') 
  }else{
    next()
  }
})
export default router
